<#assign currentTime = .now>
package ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.service.impl;

import com.neegix.application.command.BaseService;
import com.neegix.exception.BusinessRuntimeException;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.cqrs.command.BatchDelete${templateTable.javaTableName}Command;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.cqrs.command.New${templateTable.javaTableName}Command;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.cqrs.command.Update${templateTable.javaTableName}Command;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.cqrs.query.${templateTable.javaTableName}QueryRepository;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.application.service.${templateTable.javaTableName}Service;
import ${templateTable.packageName}.${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}.domain.entity.${templateTable.javaTableName}Entity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

 /**
  * This file is auto-generated by nebula-framework-generator.
  * The auto-generation plugin was developed using IntelliJ IDEA Community Edition.
  * Thanks to JetBrains for their outstanding contributions to the developer community.
  * <p>
  * The code generated by this tool is owned by the user of the tool.
  * The tool itself is copyrighted by <a href="${templateTable.copyright}">${templateTable.copyright}</a>.
  *
  * @author <a href="${templateTable.copyright}">${templateTable.copyright}</a>
  * @version ${templateTable.version}
  * @since ${currentTime?string("yyyy-MM-dd HH:mm:ss")}
  */

@Service
public class ${templateTable.javaTableName}ServiceImpl extends BaseService implements ${templateTable.javaTableName}Service{
    @Autowired
    private ${templateTable.javaTableName}QueryRepository ${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}QueryRepository;

    @Override
    public Void create${templateTable.javaTableName}(${templateTable.javaTableName}Entity ${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}Entity) {
        return commandInvoker.execute(new New${templateTable.javaTableName}Command(${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}Entity));
    }

    @Override
    public Void modify${templateTable.javaTableName}(${templateTable.javaTableName}Entity ${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}Entity) {
        return commandInvoker.execute(new Update${templateTable.javaTableName}Command(${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}Entity));
    }

    @Override
    public Void remove${templateTable.javaTableName}(List<Long> ids) {
        Integer count = ${templateTable.javaTableName[0]?lower_case+templateTable.javaTableName[1..]}QueryRepository.selectCount(ids);
        if (count.equals(0)){
            throw new BusinessRuntimeException("要删除的记录不存在！");
        }
        return commandInvoker.execute(new BatchDelete${templateTable.javaTableName}Command(ids));
    }
}
